<template>
	<view class="">
		<view class="top-bar flex align-center justify-between p-30">
			<text class="f-s-34">请选择就诊人</text>
			<img style="width: 34rpx;" src="@/static/images/homeIndex/close-ico.png" @click="close"></img>
		</view>
		<view style="height: 300px;">
			<scroll-view class="scroll-view_visit" scroll-y="true">
				<view class="card-item flex p-t-20 p-b-20 p-l-40 p-r-40" v-for="(item,index) in visitList" :key="index" @click="sureCurrentVisit(item)">
					<view class="flex flex-column" style="flex: 1;">
						<view class="flex align-center m-b-20">
							<text class="f-s-36 color-323232">{{item.name}}</text>
							<!-- <text style="border: 1px solid #4D8EFF;color: #4D8EFF;border-radius: 6rpx;" class="f-s-22 p-t-2 p-b-2 p-l-12 p-r-12 m-l-20">已绑定就诊卡</text> -->
							<text style="border: 1px solid #4D8EFF;color: #4D8EFF;border-radius: 6rpx;" class="f-s-22 p-t-2 p-b-2 p-l-12 p-r-12 m-l-20">{{relationTrans[item.relation]}}</text>
						</view>
						<view class="flex align-center f-s-28 color-666">
							<text>{{$idCard(item.idNum, 2) !=''? $idCard(item.idNum, 2)+'，':''}}</text>
							<text>{{$idCard(item.idNum, 3) !=''? $idCard(item.idNum, 3)+'岁，':''}}</text>
							<text>{{item.mobile || ''}}</text>
						</view>
					</view>
					<view class="flex align-center justify-center">
						<text class="select-visit f-s-28">选择</text>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="add-visit-card flex align-center justify-center p-20">
			<img style="width: 34rpx;" src="@/static/images/add-visit-ico.png" @click="close"></img>
			<text class="f-s-34 color-main m-l-20" @click="goadd">添加就诊人</text>
		</view>
	</view>


</template>

<script>
	import {
		getDictType
	} from "@/api/system/public.js";
	export default {
		name: 'switch-visit',
		mixins: [],
		components: {},
		data() {
			return {
				showVisitCard: false,
				visitList: [],
				relationTrans:{}
			}
		},
		props: {
			visitData: {
				type: Array,
				default: () => {
					return []
				}
			},
			relations: {
				type: Object,
				default: () => {
					return {}
				}
			}
		},
		watch: {
			visitData: {
				handler(val) {
					this.visitList = val
				},
				deep: true,
				immediate: true
			},
			relations: {
				handler(val) {
					this.relationTrans = val
				},
				deep: true,
				immediate: true
			}
		},
		created() {
		},
		mounted() {},
		updated() {},
		filters: {},
		methods: {
			goadd(){
				this.$tab.navigateTo('/pages/addHealthCard/index?jumpType=2')
				this.$emit('closeVisit')
			},
			/* 关闭就诊人列表 */
			close() {
				this.$emit('closeVisit')
			},
			sureCurrentVisit(res){
				uni.setStorageSync('currentVisitCard',JSON.stringify(res))
				this.close()
			},
		}
	}
</script>

<style lang='scss' scoped>
	.scroll-view_visit {
		width: 100%;
		height: 100%;
	
		.card-item {
			width: 94%;
			margin-left: 3%;
			margin-bottom: 20rpx;
			border-radius: 12rpx;
			background-color: #F8F8F8;
	
			.select-visit {
				padding: 8rpx 30rpx;
				background-color: #4D8EFF;
				color: #fff;
				border-radius: 12rpx;
			}
		}
	}
</style>
